<?php

class AlbumsModel extends CI_Model{

	public function __construct() {
		parent::__construct();
	}

	public function fetchPics($user,$album_name) {
		$sql = 'select image_name from pics p where p.user_name = ? and p.album_name = ?';
		$query = $this->db->query($sql, array($user,$album_name));
		$data = array();
		if ($query->num_rows() > 0)
		{
			foreach ($query->result() as $row)
			{
				$fileName = $row->image_name;
				$fileWebPath = base_url().'userPics/' .$user .'/' . $fileName;
				$data[] = $fileWebPath;
			}
		}
		return $data;
	}
	
	public function getAlbumNames($user) {
		$sql = 'select distinct(album_name) an from pics p where p.user_name = ?';
		$query = $this->db->query($sql, array($user));
		$data = array();
		if ($query->num_rows() > 0)
		{
			foreach ($query->result() as $row)
			{
				$data[] = $row->an;
			}
		}
		return $data;
	}
	

}
?>